package com.mjr.webmanage.service.impl;

import com.mjr.webmanage.mapper.DeptMapper;
import com.mjr.webmanage.pojo.Dept;
import com.mjr.webmanage.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Service
public class DeptServiceImpl implements DeptService {


    @Autowired
    private DeptMapper deptMapper;


    @Override
    public List<Dept> list() {
        List<Dept> all = deptMapper.findAll();

        return all;
    }


    @Override
    public Integer delete(Integer id) {
        Integer i = deptMapper.deleteById(id);
        return i;

    }

    @Override
    public void add(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        deptMapper.insert(dept);

    }

    @Override
    public Dept getById(Integer id) {
        Dept dept = deptMapper.getById(id);
        return dept;
    }

    @Override
    public Integer update(Dept dept) {
//        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.update(dept);

    }
}
